package com.seven.commons;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @工程名:common-utils
 * @author: sevenDay
 * @时间: 2019/4/4 15:35
 * @描述: 抽取字符串的功能
 */
public class ExtractMessageUtils {

    private static Pattern kk = Pattern.compile("(\\{[^\\}]*\\})");
    /**
     * 抽取字符串中{}括号之内的内容，返回List的数组
     * @param msg
     * @return
     */
    public static List<String> extractMessageByRegular(String msg){
        List<String> list=new ArrayList<String>();
        Matcher m = kk.matcher(msg);
        while(m.find()){
            list.add(m.group().substring(1, m.group().length()-1));
        }
        return list;
    }
}
